package com.meixiang.view.photoSelectActivity.activity;

import android.app.Activity;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.os.Bundle;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.view.View;
import android.widget.TextView;

import com.meixiang.R;
import com.meixiang.main.BaseActivity;
import com.meixiang.main.MXApplication;
import com.meixiang.view.photoSelectActivity.adapter.PhotoAlbumAdapter;
import com.meixiang.view.photoSelectActivity.util.AlbumHelper;
import com.meixiang.view.photoSelectActivity.util.Bimp;
import com.meixiang.view.photoSelectActivity.util.ImageBucket;
import com.meixiang.view.photoSelectActivity.util.ImageItem;

import java.util.ArrayList;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;

/**
 * 作者：黑哥 on 2016/5/13 15:15
 *
 * 相册 所有图片的界面
 */
public class PhotoAlbumActivity extends BaseActivity {

    @Bind(R.id.rv_recycler)
    RecyclerView mRecycler;
    //取消
    @Bind(R.id.tv_cancel)
    TextView mTvCancel;
    @Bind(R.id.tv_confirm)
    //确定
    TextView mTvConfirm;
    private Activity mActivity;


    private PhotoAlbumAdapter mAdapter;


    private ArrayList<ImageItem> dataList;
    private AlbumHelper helper;
    public static List<ImageBucket> contentList;

    public static Bitmap bitmap;
    protected void onCreate(Bundle savedInstanceState) {
        setContentView(R.layout.activity_photo_album);
        mActivity = PhotoAlbumActivity.this;
        MXApplication.mApp.AddActivity(mActivity);
        ButterKnife.bind(this);
        bitmap = BitmapFactory.decodeResource(getResources(),R.mipmap.ic_launcher);
        super.onCreate(savedInstanceState);
    }


    @Override
    protected void initTitle() {

    }

    @Override
    protected void initView() {

        helper = AlbumHelper.getHelper();
        helper.init(getApplicationContext());

        contentList = helper.getImagesBucketList(false);
        dataList = new ArrayList<ImageItem>();
        for(int i = 0; i<contentList.size(); i++){
            dataList.addAll( contentList.get(i).imageList );
        }

        mAdapter = new PhotoAlbumAdapter(context, dataList,
                Bimp.tempSelectBitmap);
        mRecycler.setLayoutManager(new StaggeredGridLayoutManager(4,StaggeredGridLayoutManager.VERTICAL));
        mRecycler.setAdapter(mAdapter);
    }

    @Override
    protected void setData() {

    }

    @Override
    public void onClick(View v) {

    }
}
